<%-- 
    Document   : post_management
    Created on : May 27, 2014, 5:20:22 PM
    Author     : ThanhTuan
--%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div id="wrapper_list_post">
    <div id="post_content">
        <div id="post_control">
            <form name="postSearch" action="postmanage" method="get">
                <select name="typeSearch">
                    <option value="title" ${typeSearch == 'title' ? 'selected':''}>Title</option>
                    <option value="user" ${typeSearch == 'user' ? 'selected':''}>User</option>
                    <option value="fullName" ${typeSearch == 'fullName' ? 'selected':''}>Full name</option>
                    <option value="content" ${typeSearch == 'content' ? 'selected':''}>Content</option>
                </select>
                <input name="keySearch" type="text"  value="${keySearch}"/>
                <input  class="btn_search" type="submit" name="action" value="Search"/>
            </form>

        </div>
        <div id="post_page">
            <form name="formOffset" action="postmanage?action=change" method="post">
                <select name="offset" onchange="changeOffset()">
                    <option value="1" ${currentOffset == 1 ? 'selected':''}>1</option>
                    <option value="2" ${currentOffset == 2 ? 'selected':''}>2</option>
                    <option value="3" ${currentOffset == 3 ? 'selected':''}>3</option>
                    <option value="4" ${currentOffset == 4 ? 'selected':''}>4</option>
                    <option value="5" ${currentOffset == 5 ? 'selected':''}>5</option>
                    <option value="6" ${currentOffset == 6 ? 'selected':''}>6</option>
                </select>
                <c:if test="${keySearch == null}">
                    <c:forEach begin="1" end="${totalPage}" var="i" >
                        <c:if test="${currentPage == i}">
                            <label>${i}</label>
                        </c:if>
                        <c:if test="${currentPage != i}">
                            <a href="postmanage?page=${i}">${i}</a>
                        </c:if>
                    </c:forEach>
                </c:if>
                <c:if test="${keySearch != null}">
                    <c:forEach begin="1" end="${totalPage}" var="i" >
                        <c:if test="${currentPage == i}">
                            <label>${i}</label>
                        </c:if>
                        <c:if test="${currentPage != i}">
                            <a href="postmanage?action=viewsearch&page=${i}">${i}</a>
                        </c:if>
                    </c:forEach>
                </c:if>
            </form>
        </div>
        <div class="mes_result">
            <c:if test="${msgResult != null}">
                ${msgResult}
            </c:if>
        </div>
        <div id="post_list">
            <table>
                <tr id="post_title">
                    <td id="col_check"><input type="checkbox" id="cb_root" onclick="selectAll()"/></td> 
                    <td id="col_title">Title</td>
                    <td id="col_user">User</td> 
                    <td id="col_date">Date post</td> 
                    <td id="col_cat">Category</td> 
                    <td id="col_active">Active</td> 
                    <td id="col_delete">Delete</td> 
                </tr>
                <c:forEach items="${listPost}" var="item">
                    <tr class="post_row">
                        <td class="col_check"><input type="checkbox" class="cb_sub" onclick="selectItem(this)" /></td> 
                        <td class="col_title"><a href="postmanage?action=editpost&postid=${item.postID}">${item.title}</a></td> 
                        <td><a href="#">${item.user.fullName}</a></td> 
                        <td>${item.postDate}</td> 
                        <td>${item.category.catName}</td> 
                        <td class="col_active">
                            <c:if test="${item.isActive() == true}">
                                <a href="postmanage?action=disable&postID=${item.postID}"><img src="/JudiBlog/img/enable.png" alt="enable"/></a>
                            </c:if>
                            <c:if test="${item.isActive() != true}">
                                    <a href="postmanage?action=enable&postID=${item.postID}"><img src="/JudiBlog/img/disable.png" alt="disable"/></a>
                            </c:if>
                        </td> 
                        <td class="col_delete"><a href="postmanage?action=delete&postID=${item.postID}"><img src="/JudiBlog/img/delete.png" alt="delete"/></a></td> 
                    </tr>
                    <td class="line" colspan="7"></td>
                </c:forEach>
            </table>
        </div>
    </div>
</div>